import java.util.Scanner;

/**
 * @author gao
 * @date 2025/9/10 13:22
 */

class ListNode {
    int val;
    ListNode next = null;

    public ListNode(int val) {
        this.val = val;
    }
}

public class Solution {
    public ListNode FindKthToTail(ListNode pHead, int k) {
        int len = 0;
        ListNode cur = pHead;
        while (cur != null) {
            len++;
            cur = cur.next;
        }

        if (len < k) {
            return null;
        }
        cur = pHead;

        while (len - k > 0) {
            cur = cur.next;
            len--;
        }

        return cur;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            int n = in.nextInt();
            ListNode head = null;
            ListNode tail = null;

            for (int i = 0; i < n; i++) {
                int val = in.nextInt();
                ListNode node = new ListNode(val);
                if (head == null) {
                    head = node;
                    tail = node;
                } else {
                    tail.next = node;
                    tail = node;
                }
            }
            int k = in.nextInt();
            Solution solution = new Solution();
            print(solution.FindKthToTail(head, k));
        }
    }

    private static void print(ListNode head) {
        ListNode cur = head;
        while (cur != null) {
            System.out.print(cur.val + " ");
            cur = cur.next;
        }
    }
}